# @Version        : 1.0
# @Update Time    : 2024/9/23 20:54
# @File           : login_record_model.py
# @IDE            : PyCharm
# @Desc           : 登录日志记录
from advanced_alchemy.base import BigIntAuditBase
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import String


class LoginRecord(BigIntAuditBase):
    __tablename__ = "sys_login_record"
    __table_args__ = {"comment": "登录日志记录"}

    username: Mapped[str | None] = mapped_column(String(50), comment="用户名")
    ipaddr: Mapped[str | None] = mapped_column(String(50), comment="登录IP地址")
    # 访问地址
    continent: Mapped[str | None] = mapped_column(String(50), comment="大洲")
    country: Mapped[str | None] = mapped_column(String(50), comment="国家")
    province: Mapped[str | None] = mapped_column(String(50), comment="省份")
    city: Mapped[str | None] = mapped_column(String(50), comment="城市")
    district: Mapped[str | None] = mapped_column(String(50), comment="区县")
    isp: Mapped[str | None] = mapped_column(String(50), comment="运营商")
    area_code: Mapped[str | None] = mapped_column(String(50), comment="区号")
    longitude: Mapped[str | None] = mapped_column(String(50), comment="经度")
    latitude: Mapped[str | None] = mapped_column(String(50), comment="纬度")
    # 浏览器
    browser: Mapped[str | None] = mapped_column(String(50), comment="浏览器")
    os: Mapped[str | None] = mapped_column(String(50), comment="操作系统")
    agent: Mapped[str | None] = mapped_column(String(500), comment="代理")
    login_type: Mapped[str | None] = mapped_column(String(32), comment="登录类型")
    params: Mapped[str | None] = mapped_column(String(255), comment="参数")
    status: Mapped[str] = mapped_column(String(1), comment="状态1:成功，2：异常")
    message: Mapped[str | None] = mapped_column(String(50), comment="响应信息")
